home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 April / macformat-023.iso / Shareware City / Developers / NeoPersist 3.0.8 folder / NeoIncludes / CNeoBlob.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-13  |  3.2 KB  |  109 lines  |  [TEXT/MMCC]

  1. /****
  2.  * CNeoBlob.h
  3.  *
  4.  *    Persistent blob class.
  5.  *
  6.  ****/
  7. #pragma once            /* Include this file only once */
  8. #ifndef __CNeoBlob__
  9. #define __CNeoBlob__ 1
  10.  
  11. #include "NeoTypes.h"
  12. #include CNeoPersistNativeH
  13.  
  14. class ENeoBlob {
  15. public:
  16.                         /** Instance Methods **/
  17.                         ENeoBlob(CNeoPersist *aContainer);
  18.                         ~ENeoBlob(void);
  19.     static NeoBlob        CacheMalloc(size_t aSize);
  20.     long                getFileLength(void) const;
  21.     void                add(void);
  22.     void                remove(void);
  23.  
  24.                         /** I/O Methods **/
  25.     void                readObject(CNeoStream *aStream, const NeoTag aTag);
  26.     void                writeObject(CNeoStream *aStream, const NeoTag aTag);
  27.     void                update(CNeoPersist *aObject);
  28.  
  29.                         /** Blob Management Methods **/
  30.     NeoBlob                getBlob(void);
  31.     long                getLength(void) const {return fLength;}
  32.     NeoMark                getMark(void) const {return fMark;}
  33.     Boolean                isBusy(void) const {return fBusy;}
  34.     Boolean                isDirty(void) const {return fDirty;}
  35.     void                setBlob(NeoBlob aBlob, const long aLength);
  36.     void                setBusy(const Boolean aBusy = TRUE) {fBusy = aBusy;}
  37.     void                setDirty(const Boolean aDirty = TRUE);
  38.  
  39.                         /** Purge Methods **/
  40.     Boolean                isPurgeable(NeoSize *aNeeded) {return purge(aNeeded);}
  41.     Boolean                purge(NeoSize *aNeeded);
  42.  
  43. #ifdef qNeoDebug
  44.                         /** Debugging Methods **/
  45.     virtual const void *verify(const void *aValue) const;
  46. #endif
  47.  
  48.                         /** Instance Variables **/
  49. protected:
  50.     Boolean                fDirty;
  51.     Boolean                fBusy;
  52.     NeoMark                fMark;
  53.     long                fLength;
  54.     NeoBlob                fBlob;
  55.     CNeoPersist *        fContainer;
  56. };
  57.  
  58. class CNeoBlob : public CNeoPersistNative
  59. {
  60. public:
  61.                         /** Instance Methods **/
  62.                         CNeoBlob(void);
  63.     static NeoBlob        CacheMalloc(size_t aSize) {return ENeoBlob::CacheMalloc(aSize);}
  64.     static CNeoPersist *New(void);
  65.     virtual NeoID        getClassID(void) const;
  66.     virtual long        getFileLength(void) const;
  67.  
  68.                         /** I/O Methods **/
  69.     virtual void        readObject(CNeoStream *aStream, const NeoTag aTag);
  70.     virtual void        writeObject(CNeoStream *aStream, const NeoTag aTag);
  71.     virtual void        update(CNeoPersist *aObject);
  72.  
  73.                         /** Persistence Methods **/
  74.     virtual void        add(void);
  75.     virtual void        remove(void);
  76.  
  77.                         /** Blob Management Methods **/
  78.     NeoBlob                getBlob(void) {return fBlob.getBlob();}
  79.     long                getBlobLength(void) const {return fBlob.getLength();}
  80.     NeoMark                getBlobMark(void) const {return fBlob.getMark();}
  81.     Boolean                isBlobBusy(void) const {return fBlob.isBusy();}
  82.     Boolean                isBlobDirty(void) const {return fBlob.isDirty();}
  83.     void                setBlob(NeoBlob aBlob, const long aLength) {fBlob.setBlob(aBlob, aLength);}
  84.     void                setBlobBusy(const Boolean aBusy) {fBlob.setBusy(aBusy);}
  85.     void                setBlobDirty(const Boolean aDirty = TRUE) {fBlob.setDirty(aDirty);}
  86.  
  87.                         /** Purge Methods **/
  88.     virtual Boolean        isPurgeable(NeoSize *aNeeded);
  89.     virtual Boolean        purge(NeoSize *aNeeded);
  90.     Boolean                purgeBlob(NeoSize *aNeeded) {return fBlob.purge(aNeeded);}
  91.  
  92. protected:
  93. #ifdef qNeoDebug
  94.                         /** Debugging Methods **/
  95.     virtual const void *verify(const void *aValue) const;
  96. #endif
  97.  
  98.                         /** Instance Variables **/
  99.     ENeoBlob            fBlob;
  100. };
  101.  
  102. enum {kENeoBlobFileLength        = (sizeof(NeoMark) + sizeof(long))};
  103. enum {kNeoBlobFileLength        = kNeoPersistFileLength + kENeoBlobFileLength};
  104.  
  105. const NeoTag    pBlobMark        = Neo4CharConst('BB','mk');
  106. const NeoTag    pBlobLength        = Neo4CharConst('BB','ln');
  107. const NeoTag    pBlobData        = Neo4CharConst('BB','dt');
  108. #endif
  109.